//
// File:	EntityDataMap.cpp
// Author:	Thomas TISSOT-DUPONT
// Login:	<thomas.tissotdupont@free.fr>
//
// Created:	22/04/2010 at 23:24:26
// Purpose:	
//

#include "EntityDataMap.hpp"
#include "Trace.hpp"

//------------------------------------------------------------------
// DataMapField > Constructor / Destructor
//------------------------------------------------------------------
DataMapField::DataMapField()
	:	m_pVariable(NULL),
		m_pFnWriter(NULL)
{
}

DataMapField::DataMapField(const DataMapField &other)
	:	m_pVariable(other.m_pVariable),
		m_pFnWriter(other.m_pFnWriter)
{
}

//------------------------------------------------------------------
// DataMapField > Operators
//------------------------------------------------------------------
void DataMapField::operator()(const Variant &v)
{
	if (m_pVariable && m_pFnWriter)
	{
		(this->*m_pFnWriter)(v);
	}
}
DataMapField &DataMapField::operator=(const DataMapField &other)
{
	m_pVariable = other.m_pVariable;
	m_pFnWriter = other.m_pFnWriter;
	return *this;
}

//------------------------------------------------------------------
// EntityDataMap > Write
//------------------------------------------------------------------
void EntityDataMap::Write(const std::string &name, const Variant &v)
{
	if (m_fields.find(name) != m_fields.end())
	{
		m_fields[name](v);
	}
}
